
/* GENERATED CODE:
 *  Any modifications you make are guaranteed
 *  to be deleted when this is regenerated.
 * Please edit "PROTOCOLS" inside this directory
 *
 * Names are all upper case because of "String" and "string."
 */

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using OWED.Network.Messages.General;
using OWED.Network.Messages;
using OWED.Network.Messages.Reply;


namespace OWED.Network.Messages.General
{
	public class Permission: IProtocolItem 
	{
		bool my_read;
		bool my_write;
		bool my_admin;
		public Permission (bool read, bool write, bool admin)
		{
			my_read = read;
			my_write = write;
			my_admin = admin;
		}
		public bool read { get { return my_read; } }
		public bool write { get { return my_write; } }
		public bool admin { get { return my_admin; } }


		public static new Permission FromXml(XmlDocument xml)
		{
			bool read = bool.Parse(xml.SelectSingleNode("Permission").Attributes.GetNamedItem("read").Value);
			bool write = bool.Parse(xml.SelectSingleNode("Permission").Attributes.GetNamedItem("write").Value);
			bool admin = bool.Parse(xml.SelectSingleNode("Permission").Attributes.GetNamedItem("admin").Value);
			return new Permission(read, write, admin);
		}


		public override XmlDocument ToXml()		{
			XmlDocument doc = new XmlDocument();

			doc.AppendChild(doc.CreateElement("Permission"));
			XmlAttribute attr;
			attr = doc.CreateAttribute("read");
			attr.Value = my_read.ToString();
			doc.FirstChild.Attributes.Append(attr);

			attr = doc.CreateAttribute("write");
			attr.Value = my_write.ToString();
			doc.FirstChild.Attributes.Append(attr);

			attr = doc.CreateAttribute("admin");
			attr.Value = my_admin.ToString();
			doc.FirstChild.Attributes.Append(attr);


			return doc;
		}
	}
}
